<style>
.setimg{
	margin:-2px 5px 0 0 
}
</style>
<div class="row-fluid">
	<a style="border:1px solid #ccc" class="block-heading" data-toggle="collapse">列表数据</a>
    <div class="well">
	    <div class="btn-toolbar">
		    <form>
		    	<label style="display: inline;">用户名称：</label><input class="input input-medium" type="text" name="cust_name" value="<?=I('get.cust_name')?>" />
		    	<label style="display: inline;margin-left:10px">订单编号：</label><input class="input input-medium" type="text" name="order_id" value="<?=I('get.order_id')?>" />
		    	<label style="display: inline;margin-left:10px">用户id：</label><input class="input input-medium" style="width:60px" type="text" name="cust_id" value="<?=I('get.cust_id')?>" />
		    	
		    	<label style="display: inline;margin-left:10px">手机号码：</label><input class="input input-medium" type="text" name="cust_mobile" value="<?=I('get.cust_mobile')?>" />
		    	<label style="display: inline;margin-left:10px">订单状态：</label>
			 	<?php $getOrderStatus = C('ostatus');?>
			 	<select name="st">
			 		<option value="all">全部</option>
			 		<?php if($getOrderStatus){foreach($getOrderStatus AS $ks=>$val){?>
			 		<option <?= strval($ks) == strval(I('get.st')) && isset($_GET['st']) ? 'selected="selected"' : ''?> value=<?=$ks?>><?=$val?></option>
			 		<?php }}?>
			 	</select>
		    	<input type="hidden" value="<?=I('get.res')?>" name="res" />
		    	<button class="btn btn-info" style="margin:-9px 0 0 15px"><i class="icon-search"></i> 搜索</button>
		    </form>
		</div>
		<hr>
		<table class="table">
		      <thead>
		        <tr>
		          <th style="text-align:center;width:110px">订单编号</th>
		          <th style="text-align:center;width:180px">用户信息</th>
		          <th style="text-align:center;width:350px">商品信息</th>
		          <th style="text-align:center;width:350px">收货信息</th>
		          <th style="text-align:center;width:190px">订单状态</th>
		          <th style="text-align:center;width:250px">订单生成时间</th>
		      	  <th style="text-align:center;width:130px">操作</th>
		        </tr>
		      </thead>
		      <tbody>
		      	<?php if($getData){foreach($getData AS $key=>$val){ $order_status = C('ostatus')?>
		        <tr> 
		          <td style="text-align:center;vertical-align:middle"><?=$val['order_id']?><br/>

					  <if condition="$val['remark'] neq null">
						  <a class="ifrm" href="javascript:void(0)" data-url="/order/addRemark" style="padding: 0px 4px;" data-width="450" data-height="360" data-title="订单备注" data-params="oid/<?=$val['order_id']?>" title="订单备注">已备注</a>
						  <else/>
						  <a class="ifrm" href="javascript:void(0)" data-url="/order/addRemark" style="padding: 0px 4px;" data-width="450" data-height="360" data-title="订单备注" data-params="oid/<?=$val['order_id']?>" title="订单备注">订单备注</a>
					  </if>
					  <if condition="$val['service_mark'] neq null">
						  <a class="ifrm" href="javascript:void(0)" data-url="/order/addServiceMark" style="padding: 0px 4px;" data-width="450" data-height="360" data-title="客服备注" data-params="oid/<?=$val['order_id']?>" title="客服备注">客服已备注</a>
						  <else/>
						  <a class="ifrm" href="javascript:void(0)" data-url="/order/addServiceMark" style="padding: 0px 4px;" data-width="450" data-height="360" data-title="客服备注" data-params="oid/<?=$val['order_id']?>" title="客服备注">客服备注</a>
					  </if>
					  <!--<a class="ifrm" href="javascript:void(0)" data-url="/order/addRemark" style="padding: 0px 4px;" data-width="450" data-height="360" data-title="订单备注" data-params="oid/<?=$val['order_id']?>" title="订单备注">订单备注</a>-->
				  </td>
		          <td style="text-align:center;vertical-align:middle"><a href="/index/index/cust_id/<?=$val['cust_id']?>"><?=$val['nickname'] ?: '-'?> / <?=$val['cust_mobile'] ?: '-'?></a></td>
		       	  <td style="text-align:center;vertical-align:middle"><center>
		       	  	<table>
				  	<?php $nums = 0;$oemnums = 0;$oemprice = 0;$getGoods = M('OrderCollect')->where(array('order_id'=>$val['order_id']))->select();if($getGoods){foreach($getGoods AS $vv){$nums += $vv['pay_nums']?>
				  		<tr>
							<td style="text-align:center;">
								<if condition="$vv['type'] eq 2">
									<?php
										$oemnums += $vv['pay_nums'];
										$oemprice += $vv['pay_nums']*$vv['pay_price'];
									?>
									<span class="label label-warning" style="background-color:#93D6CD">OEM商品</span>
								</if>
								<?=$vv['goods_title']?>
							</td>
							<td style="text-align:center;"> × <?=$vv['pay_nums']?></td>
							<td style="text-align:center;"><?=$vv['pay_price']?> 元</td>
						</tr>
				  	<?php }}else{?>
				  		<tr>
							<td style="text-align:center;" colspan=3>
								<if condition="$val['order_type'] eq 1">
									<?php
										$remark = explode('_',$val['remark']);
										if($remark[0]=='0'){
											echo "升级嗨呗专员";
										}else if($remark[0]=='1'){
											echo "升级嗨呗经理";
										}else if($remark[0]=='2'){
											echo "嗨呗专员升级嗨呗经理";
										}else{
											echo "没有数据";
										}
									?>
								<else/>
									没有数据
								</if>
							</td>
						</tr>
				  	<?php }?>
					<tr>
						<if condition="$oemnums gt 0">
							<td style="text-align:center;">OEM商品总计</td><td style="text-align:center;"> × <?=$oemnums?></td>
							<td style="text-align:center;"><?=$oemprice?> 元</td>
						</if>
					</tr>
				  	<tr>
						<td style="text-align:center;">总计</td><td style="text-align:center;"> × <?=$nums?></td>
						<td style="text-align:center;"><?=$val['order_pay']?> 元</td>
					</tr>
				  	</table></center>
				  </td>
					<!--<td style="text-align:center;vertical-align:middle">{{$val['receive_address']|default='-'}}</td>-->
					<td style="text-align:center;vertical-align:middle">
						<if condition="$val['receive_address']">
							<center>
							<table>
								<tr>
									<td style="text-align:center;">姓名：{{$val['receive_name']}}</td>
								</tr>
								<tr>
									<td style="text-align:center;">手机号码：{{$val['receive_mobile']}}</td>
								</tr>
								<tr>
									<td style="text-align:center;">身份证：{{$val['receive_identity']}}</td>
								</tr>
								<tr>
									<td style="text-align:center;">地址：{{$val['receive_address']}}</td>
								</tr>
							</table>
							</center>
						<else/>
							-
						</if>
					</td>
		          <td style="text-align:center;vertical-align:middle">
					  <span class="label label-<?=!$val['order_status'] ? 'defalut' : 'info'?>">
						  <?=$order_status[$val['order_status']]?>
					  </span>
					  <p>
						  <if condition="$val['order_status'] eq 2">
							  <a class="ifrm" href="javascript:void(0)" data-url="/order/showExpress" style="padding: 0px 4px;" data-width="450" data-height="360" data-title="查看物流" data-params="order_id/<?=$val['order_id']?>" title="查看物流">查看物流</a>
						  </if>
					  </p>
				  </td>
		       	  <td style="text-align:center;vertical-align:middle"><?=date('Y-m-d H:i:s',$val['add_at'])?></td>
		          <td style="text-align:center;vertical-align:middle">
					  <if condition="$val['order_type'] neq 1">
					  <?php if(in_array($val['order_status'],array('0'))){?>
					  <a href="/order/cancle?oid=<?=$val['order_id']?>" class="btn btn-danger deletes" style="padding: 0px 4px;" role="button" title="订单作废" data-title="订单作废"  data-toggle="modal"><i class="icon-remove-sign"></i></a>&nbsp;&nbsp;
				      <?php }elseif(in_array($val['order_status'],array('5'))){?>
						  <a class="ifrm btn btn-warning" href="javascript:void(0)" data-url="/order/refundly" style="padding: 0px 4px;" data-width="670" data-height="410" data-title="退货理由" data-params="oid/<?=$val['order_id']?>"><i class="icon-eye-open"></i></a>&nbsp;&nbsp;
					  <a class="ifrm btn btn-warning" href="javascript:void(0)" data-url="/order/refund" style="padding: 0px 4px;" data-width="670" data-height="410" data-title="订单售后" data-params="oid/<?=$val['order_id']?>"><i class="icon-hand-up"></i></a>&nbsp;&nbsp;
					  <?php }elseif($val['order_status'] == '6' && $val['refund_expressnum']){?>
						  <a class="ifrm btn btn-warning" href="javascript:void(0)" data-url="/order/refundwl" style="padding: 0px 4px;" data-width="670" data-height="410" data-title="退货物流" data-params="oid/<?=$val['order_id']?>"><i class="icon-eye-open"></i></a>&nbsp;&nbsp;
						  <!--<a class="ifrm btn btn-warning" href="javascript:void(0)" data-url="/order/refundmon" style="padding: 0px 4px;" data-width="670" data-height="410" data-title="售后退款" data-params="oid/<?=$val['order_id']?>"><i class="icon-hand-up"></i></a>&nbsp;&nbsp;-->
					  <?php }elseif(in_array($val['order_status'],array('1'))){?>
						  <if condition="$oemprice gt 0">
							  <a class="ifrm btn btn-warning" href="javascript:void(0)" data-url="/order/send" style="padding: 0px 4px;" data-width="450" data-height="360" data-title="订单发货" data-params="oid/<?=$val['order_id']?>"><i class="icon-hand-up"></i></a>&nbsp;&nbsp;
						  </if>
					  <?php }else{?>
				      	-
				      <?php }?>
					  <else/>
						  -
					  </if>
				 </td>
		        </tr>
		        <?php }}else{?>
		        <td style="text-align:center;" colspan=7>暂无订单</td></tbody>
		        <?php }?>
		      </tbody>
	   </table>
	   <span style="float:right;margin-top:-44px"><?=$page?></span>
	</div>
</div>
<script>
$(function(){
	$('.deletes').click(function(){
		if(!window.confirm('确认取消该订单吗 ?')){
			return false;
		}
		window.location = $(this).attr('href');
	});
})
</script>